<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen">
</head>
<body>
    <div class="entry"> 
 <div id="toc">
  <strong>目录</strong>
  <span>[hide]</span> 
  <ul id="toc_l"> 
   <li><a href="#Uninitialize_reason_codes">未初始化原因代码</a></li> 
   <li><a href="#Special_constants">特殊常量 </a></li> 
   <li><a href="#Error_codes">错误代码</a></li> 
  </ul> 
 </div> 
 <p>为了简化程序编写，使程序文本编辑使用起来更加简便，在MQL4中预定义了标准常量。</p> 
 <p>标准常量类似于宏代换，并且是<a href="368.html#Integer_constants">int(整数类型)</a>。</p> 
 <p>这些常量按用途进行分组。</p> 
 <h2><a name="Uninitialize_reason_codes"></a>未初始化原因代码</h2> 
 <p>使用<a href="386.html#UninitializeReason">UninitializeReason() 函数</a>返回未初始化原因代码。可以是以下任意值:</p> 
 <table class="custom-table"> 
  <tbody> 
   <tr> 
    <th width="15%">常数</th> 
    <th width="10%">值</th> 
    <th width="75%">描述</th> 
   </tr> 
   <tr> 
    <td></td> 
    <td>0</td> 
    <td>脚本独立执行完成</td> 
   </tr> 
   <tr> 
    <td>REASON_REMOVE</td> 
    <td>1</td> 
    <td>从图表中删除智能交易。</td> 
   </tr> 
   <tr> 
    <td>REASON_RECOMPILE</td> 
    <td>2</td> 
    <td>重新编译智能交易。</td> 
   </tr> 
   <tr> 
    <td>REASON_CHARTCHANGE</td> 
    <td>3</td> 
    <td>改变了图表货币对和时间周期。</td> 
   </tr> 
   <tr> 
    <td>REASON_CHARTCLOSE</td> 
    <td>4</td> 
    <td>关闭图表</td> 
   </tr> 
   <tr> 
    <td>REASON_PARAMETERS</td> 
    <td>5</td> 
    <td>用户改变了输入参数</td> 
   </tr> 
   <tr> 
    <td>REASON_ACCOUNT</td> 
    <td>6</td> 
    <td>其他账户已激活</td> 
   </tr> 
  </tbody> 
 </table> 
 <div class="divider top-of-page">
  <a title="Top of Page" href="#top">Back to Top</a>
 </div> 
 <h2><a name="Special_constants"></a>特殊常量</h2> 
 <p>特殊常量用于描述参数和变量状态。可以是以下任意值:</p> 
 <table class="custom-table"> 
  <tbody> 
   <tr> 
    <th width="15%">常数</th> 
    <th width="10%">值</th> 
    <th width="75%">描述</th> 
   </tr> 
   <tr> 
    <td>NULL</td> 
    <td>0</td> 
    <td>表明字符串为空值。</td> 
   </tr> 
   <tr> 
    <td>EMPTY</td> 
    <td>-1</td> 
    <td>表明参数为空值。</td> 
   </tr> 
   <tr> 
    <td>EMPTY_值</td> 
    <td>0x7FFFFFFF</td> 
    <td>默认自定义指标为空值。</td> 
   </tr> 
   <tr> 
    <td>CLR_NONE</td> 
    <td>0xFFFFFFFF</td> 
    <td>表明颜色为空值。</td> 
   </tr> 
   <tr> 
    <td>WHOLE_ARRAY</td> 
    <td>0</td> 
    <td>配合数组函数应用，表示数组所有元素将被处理。</td> 
   </tr> 
  </tbody> 
 </table> 
 <div class="divider top-of-page">
  <a title="Top of Page" href="#top">Back to Top</a>
 </div> 
 <h2><a name="Error_codes"></a>错误代码</h2> 
 <p><a href="386.html#GetLastError">GetLastError()函数</a>返回出错代码，错误代码常量定义在stderror.mqh文件里。想要获取错误的文本信息，请调用在stdlib. mqh文件中定义的ErrorDescription()函数。</p> 
 <pre class="brush: mql4; toolbar: false;">#include &lt;stderror.mqh&gt;
#include &lt;stdlib.mqh&gt;
void SendMyMessage(string text)
  {
   int check;
   SendMail("some subject", text);
   check=GetLastError();
   if(check!=ERR_NO_ERROR) Print("Cannot send message, error: ",Error描述(check));
  }</pre> 
 <p>从服务器返回的错误代码及描述说明</p> 
 <table class="custom-table"> 
  <tbody> 
   <tr> 
    <th width="15%">常数</th> 
    <th width="10%">值</th> 
    <th width="75%">描述</th> 
   </tr> 
   <tr> 
    <td>ERR_NO_ERROR</td> 
    <td>0</td> 
    <td>没有错误返回。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_RESULT</td> 
    <td>1</td> 
    <td>没有错误返回，但结果不明。</td> 
   </tr> 
   <tr> 
    <td>ERR_COMMON_ERROR</td> 
    <td>2</td> 
    <td>一般错误。</td> 
   </tr> 
   <tr> 
    <td>ERR_INVALID_TRADE_PARAMETERS</td> 
    <td>3</td> 
    <td>无效交易参数。</td> 
   </tr> 
   <tr> 
    <td>ERR_SERVER_BUSY</td> 
    <td>4</td> 
    <td>交易服务器繁忙。</td> 
   </tr> 
   <tr> 
    <td>ERR_OLD_VERSION</td> 
    <td>5</td> 
    <td>客户终端版本太旧。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_CONNECTION</td> 
    <td>6</td> 
    <td>没有连接服务器。</td> 
   </tr> 
   <tr> 
    <td>ERR_NOT_ENOUGH_RIGHTS</td> 
    <td>7</td> 
    <td>没有权限。</td> 
   </tr> 
   <tr> 
    <td>ERR_TOO_FREQUENT_REQUESTS</td> 
    <td>8</td> 
    <td>请求过于频繁。</td> 
   </tr> 
   <tr> 
    <td>ERR_MALFUNCTIONAL_TRADE</td> 
    <td>9</td> 
    <td>无效交易。</td> 
   </tr> 
   <tr> 
    <td>ERR_ACCOUNT_DISABLED</td> 
    <td>64</td> 
    <td>账户禁用。</td> 
   </tr> 
   <tr> 
    <td>ERR_INVALID_ACCOUNT</td> 
    <td>65</td> 
    <td>无效账户</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_TIMEOUT</td> 
    <td>128</td> 
    <td>交易超时。</td> 
   </tr> 
   <tr> 
    <td>ERR_INVALID_PRICE</td> 
    <td>129</td> 
    <td>无效价格。</td> 
   </tr> 
   <tr> 
    <td>ERR_INVALID_STOPS</td> 
    <td>130</td> 
    <td>无效平仓。</td> 
   </tr> 
   <tr> 
    <td>ERR_INVALID_TRADE_VOLUME</td> 
    <td>131</td> 
    <td>无效交易量。</td> 
   </tr> 
   <tr> 
    <td>ERR_MARKET_CLOSED</td> 
    <td>132</td> 
    <td>市场关闭。</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_DISABLED</td> 
    <td>133</td> 
    <td>交易被禁止。</td> 
   </tr> 
   <tr> 
    <td>ERR_NOT_ENOUGH_MONEY</td> 
    <td>134</td> 
    <td>资金不足。</td> 
   </tr> 
   <tr> 
    <td>ERR_PRICE_CHANGED</td> 
    <td>135</td> 
    <td>价格已变动。</td> 
   </tr> 
   <tr> 
    <td>ERR_OFF_QUOTES</td> 
    <td>136</td> 
    <td>无报价。</td> 
   </tr> 
   <tr> 
    <td>ERR_BROKER_BUSY</td> 
    <td>137</td> 
    <td>经纪繁忙。</td> 
   </tr> 
   <tr> 
    <td>ERR_REQUOTE</td> 
    <td>138</td> 
    <td>重新报价。</td> 
   </tr> 
   <tr> 
    <td>ERR_ORDER_LOCKED</td> 
    <td>139</td> 
    <td>定单被锁定。</td> 
   </tr> 
   <tr> 
    <td>ERR_LONG_POSITIONS_ONLY_ALLOWED</td> 
    <td>140</td> 
    <td>只允许多头头寸。</td> 
   </tr> 
   <tr> 
    <td>ERR_TOO_MANY_REQUESTS</td> 
    <td>141</td> 
    <td>请求过多。</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_MODIFY_DENIED</td> 
    <td>145</td> 
    <td>因为订单过于接近市价，修改被拒绝。</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_CONTEXT_BUSY</td> 
    <td>146</td> 
    <td>交易系统忙。</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_EXPIRATION_DENIED</td> 
    <td>147</td> 
    <td>交易过期，被经纪商拒绝。</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_TOO_MANY_ORDERS</td> 
    <td>148</td> 
    <td>开仓和挂单总数已经达到经纪商的限定。</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_HEDGE_PROHIBITED</td> 
    <td>149</td> 
    <td>当对冲功能被关闭时，尝试开仓一个和现有仓位相反的订单。</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_PROHIBITED_BY_FIFO</td> 
    <td>150</td> 
    <td>尝试关闭一个违反FIFO规则的订单。</td> 
   </tr> 
  </tbody> 
 </table> 
 <p>MQL4 运行时错误代码</p> 
 <table class="custom-table"> 
  <tbody> 
   <tr> 
    <th width="15%">常数</th> 
    <th width="10%">值</th> 
    <th width="75%">描述</th> 
   </tr> 
   <tr> 
    <td>ERR_NO_MQLERROR</td> 
    <td>4000</td> 
    <td>没有错误。</td> 
   </tr> 
   <tr> 
    <td>ERR_WRONG_FUNCTION_POINTER</td> 
    <td>4001</td> 
    <td>错误函数指针。</td> 
   </tr> 
   <tr> 
    <td>ERR_ARRAY_INDEX_OUT_OF_RANGE</td> 
    <td>4002</td> 
    <td>数组索引（下标）超出范围。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_MEMORY_FOR_CALL_STACK</td> 
    <td>4003</td> 
    <td>没有足够内存开设函数调用堆栈。</td> 
   </tr> 
   <tr> 
    <td>ERR_RECURSIVE_STACK_OVERFLOW</td> 
    <td>4004</td> 
    <td>递归堆栈溢出。</td> 
   </tr> 
   <tr> 
    <td>ERR_NOT_ENOUGH_STACK_FOR_PARAM</td> 
    <td>4005</td> 
    <td>没有足够堆栈储存参数。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_MEMORY_FOR_PARAM_STRING</td> 
    <td>4006</td> 
    <td>没有足够内存储存字符串参数。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_MEMORY_FOR_TEMP_STRING</td> 
    <td>4007</td> 
    <td>没有足够内存保存临时字符串。</td> 
   </tr> 
   <tr> 
    <td>ERR_NOT_INITIALIZED_STRING</td> 
    <td>4008</td> 
    <td>没有初始化字符串。</td> 
   </tr> 
   <tr> 
    <td>ERR_NOT_INITIALIZED_ARRAYSTRING</td> 
    <td>4009</td> 
    <td>在数组中没有初始化字符串。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_MEMORY_FOR_ARRAYSTRING</td> 
    <td>4010</td> 
    <td>没有足够内存保存字符串数组。</td> 
   </tr> 
   <tr> 
    <td>ERR_TOO_LONG_STRING</td> 
    <td>4011</td> 
    <td>字符串过长。</td> 
   </tr> 
   <tr> 
    <td>ERR_REMAINDER_FROM_ZERO_DIVIDE</td> 
    <td>4012</td> 
    <td>余额除零。</td> 
   </tr> 
   <tr> 
    <td>ERR_ZERO_DIVIDE</td> 
    <td>4013</td> 
    <td>除零。</td> 
   </tr> 
   <tr> 
    <td>ERR_UNKNOWN_COMMAND</td> 
    <td>4014</td> 
    <td>不明命令。</td> 
   </tr> 
   <tr> 
    <td>ERR_WRONG_JUMP</td> 
    <td>4015</td> 
    <td>错误跳转(不产生错误)。</td> 
   </tr> 
   <tr> 
    <td>ERR_NOT_INITIALIZED_ARRAY</td> 
    <td>4016</td> 
    <td>没有初始化数组。</td> 
   </tr> 
   <tr> 
    <td>ERR_DLL_CALLS_NOT_ALLOWED</td> 
    <td>4017</td> 
    <td>禁止调用DLL 。</td> 
   </tr> 
   <tr> 
    <td>ERR_CANNOT_LOAD_LIBRARY</td> 
    <td>4018</td> 
    <td>不能加载库。</td> 
   </tr> 
   <tr> 
    <td>ERR_CANNOT_CALL_FUNCTION</td> 
    <td>4019</td> 
    <td>不能调用函数。</td> 
   </tr> 
   <tr> 
    <td>ERR_EXTERNAL_CALLS_NOT_ALLOWED</td> 
    <td>4020</td> 
    <td>禁止调用智能交易函数。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_MEMORY_FOR_RETURNED_STR</td> 
    <td>4021</td> 
    <td>没有足够内存保存函数返回的字符串。</td> 
   </tr> 
   <tr> 
    <td>ERR_SYSTEM_BUSY</td> 
    <td>4022</td> 
    <td>系统繁忙 (不产生错误)。</td> 
   </tr> 
   <tr> 
    <td>ERR_INVALID_FUNCTION_PARAMSCNT</td> 
    <td>4050</td> 
    <td>非法函数参数个数。</td> 
   </tr> 
   <tr> 
    <td>ERR_INVALID_FUNCTION_PARAM值</td> 
    <td>4051</td> 
    <td>非法函数参数值。</td> 
   </tr> 
   <tr> 
    <td>ERR_STRING_FUNCTION_INTERNAL</td> 
    <td>4052</td> 
    <td>字符串函数内部出错。</td> 
   </tr> 
   <tr> 
    <td>ERR_SOME_ARRAY_ERROR</td> 
    <td>4053</td> 
    <td>数组错误。</td> 
   </tr> 
   <tr> 
    <td>ERR_INCORRECT_SERIESARRAY_USING</td> 
    <td>4054</td> 
    <td>使用了错误的序列数组。</td> 
   </tr> 
   <tr> 
    <td>ERR_CUSTOM_INDICATOR_ERROR</td> 
    <td>4055</td> 
    <td>自定义指标错误。</td> 
   </tr> 
   <tr> 
    <td>ERR_INCOMPATIBLE_ARRAYS</td> 
    <td>4056</td> 
    <td>数组不兼容。</td> 
   </tr> 
   <tr> 
    <td>ERR_GLOBAL_VARIABLES_PROCESSING</td> 
    <td>4057</td> 
    <td>全局变量处理错误。</td> 
   </tr> 
   <tr> 
    <td>ERR_GLOBAL_VARIABLE_NOT_FOUND</td> 
    <td>4058</td> 
    <td>全局变量未找到。</td> 
   </tr> 
   <tr> 
    <td>ERR_FUNC_NOT_ALLOWED_IN_TESTING</td> 
    <td>4059</td> 
    <td>不许在测试模式使用函数。</td> 
   </tr> 
   <tr> 
    <td>ERR_FUNCTION_NOT_CONFIRMED</td> 
    <td>4060</td> 
    <td>函数不被允许</td> 
   </tr> 
   <tr> 
    <td>ERR_SEND_MAIL_ERROR</td> 
    <td>4061</td> 
    <td>发送邮件错误。</td> 
   </tr> 
   <tr> 
    <td>ERR_STRING_PARAMETER_EXPECTED</td> 
    <td>4062</td> 
    <td>要求字符串参数。</td> 
   </tr> 
   <tr> 
    <td>ERR_INTEGER_PARAMETER_EXPECTED</td> 
    <td>4063</td> 
    <td>要求整数参数。</td> 
   </tr> 
   <tr> 
    <td>ERR_DOUBLE_PARAMETER_EXPECTED</td> 
    <td>4064</td> 
    <td>要求双精度参数。</td> 
   </tr> 
   <tr> 
    <td>ERR_ARRAY_AS_PARAMETER_EXPECTED</td> 
    <td>4065</td> 
    <td>要求用数组作参数。</td> 
   </tr> 
   <tr> 
    <td>ERR_HISTORY_WILL_UPDATED</td> 
    <td>4066</td> 
    <td>正在更新历史数据。</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_ERROR</td> 
    <td>4067</td> 
    <td>交易执行出错。</td> 
   </tr> 
   <tr> 
    <td>ERR_END_OF_FILE</td> 
    <td>4099</td> 
    <td>到了文件尾。</td> 
   </tr> 
   <tr> 
    <td>ERR_SOME_FILE_ERROR</td> 
    <td>4100</td> 
    <td>文件错误。</td> 
   </tr> 
   <tr> 
    <td>ERR_WRONG_FILE_NAME</td> 
    <td>4101</td> 
    <td>错误文件名称。</td> 
   </tr> 
   <tr> 
    <td>ERR_TOO_MANY_OPENED_FILES</td> 
    <td>4102</td> 
    <td>打开文件过多。</td> 
   </tr> 
   <tr> 
    <td>ERR_CANNOT_OPEN_FILE</td> 
    <td>4103</td> 
    <td>不能打开文件。</td> 
   </tr> 
   <tr> 
    <td>ERR_INCOMPATIBLE_FILEACCESS</td> 
    <td>4104</td> 
    <td>不兼容文件访问。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_ORDER_SELECTED</td> 
    <td>4105</td> 
    <td>没有选择定单。</td> 
   </tr> 
   <tr> 
    <td>ERR_UNKNOWN_SYMBOL</td> 
    <td>4106</td> 
    <td>未知货币对。</td> 
   </tr> 
   <tr> 
    <td>ERR_INVALID_PRICE_PARAM</td> 
    <td>4107</td> 
    <td>交易函数的价格参数无效。</td> 
   </tr> 
   <tr> 
    <td>ERR_INVALID_TICKET</td> 
    <td>4108</td> 
    <td>无效定单编号。</td> 
   </tr> 
   <tr> 
    <td>ERR_TRADE_NOT_ALLOWED</td> 
    <td>4109</td> 
    <td>不允许交易。在智能交易中勾选”Allow live trading(允许实时交易)”。</td> 
   </tr> 
   <tr> 
    <td>ERR_LONGS_NOT_ALLOWED</td> 
    <td>4110</td> 
    <td>不允许多头。检查智能交易属性。</td> 
   </tr> 
   <tr> 
    <td>ERR_SHORTS_NOT_ALLOWED</td> 
    <td>4111</td> 
    <td>不允许空头。检查智能交易属性。</td> 
   </tr> 
   <tr> 
    <td>ERR_OBJECT_ALREADY_EXISTS</td> 
    <td>4200</td> 
    <td>对象己经存在。</td> 
   </tr> 
   <tr> 
    <td>ERR_UNKNOWN_OBJECT_PROPERTY</td> 
    <td>4201</td> 
    <td>未知对象属性。</td> 
   </tr> 
   <tr> 
    <td>ERR_OBJECT_DOES_NOT_EXIST</td> 
    <td>4202</td> 
    <td>对象不存在。</td> 
   </tr> 
   <tr> 
    <td>ERR_UNKNOWN_OBJECT_TYPE</td> 
    <td>4203</td> 
    <td>未知对象类型。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_OBJECT_NAME</td> 
    <td>4204</td> 
    <td>缺少对象名称。</td> 
   </tr> 
   <tr> 
    <td>ERR_OBJECT_COORDINATES_ERROR</td> 
    <td>4205</td> 
    <td>对象坐标错误。</td> 
   </tr> 
   <tr> 
    <td>ERR_NO_SPECIFIED_SUBWINDOW</td> 
    <td>4206</td> 
    <td>没有找到子窗口。</td> 
   </tr> 
   <tr> 
    <td>ERR_SOME_OBJECT_ERROR</td> 
    <td>4207</td> 
    <td>对象函数错误。</td> 
   </tr> 
  </tbody> 
 </table> 
 <div class="divider top-of-page">
  <a title="Top of Page" href="#top">Back to Top</a>
 </div> 本文地址：
 <a href="377.html" rel="bookmark"><b>377.html</b></a> 
</div>
</body>
</html>